﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Text.RegularExpressions;

namespace HalloJSON.CommenData
{
    public static class StringTool
    {
        public static string GetKName(String combinName)
        {
            try
            { 
                String cheat="";
                if (Regex.Match(combinName, "\\(.*\\)").Captures.Count != 0)
                {
                    cheat = Regex.Match(combinName, "\\(.*\\)").Captures[0].Value.Substring(1, Regex.Match(combinName, "\\(.*\\)").Captures[0].Value.Length - 2);
                }
                return cheat;
            }
            catch (ArgumentNullException) { 
            return "";
            }
        }

        public static string GetTypeName(String combinName)
        {
            try
            {
                String cheat = "";
                if (Regex.Match(combinName, "\\(.*\\)").Captures.Count != 0)
                {
                    cheat = combinName.Substring(0,combinName.IndexOf("(")-2);
                }
                return cheat;
            }
            catch (ArgumentNullException)
            {
                return "";
            }
        }

        public static string TakeOffString(String pointString)
        {
            return pointString.Substring(1, pointString.Length-1);
        }
    }
}
